import tkinter as tk
from tkinter import messagebox
from tkinter import colorchooser as ch

class application(tk.Frame):
    def __init__(self,master=None):
        self.master=master
        super().__init__(master)
        self.creatWidget()

    def creatWidget(self):
        self.btn01=tk.Button(self.master,text="选择颜色",command=self.color)
        self.btn01.pack()

    def color(self):
        cl=ch.askcolor(color='red',title='选择背景颜色')
        self.master.config(bg=cl[1])



window=tk.Tk()
window.geometry('1000x300')
app=application(window)
window.mainloop()